<div class="orgInfo">
    <div class="tree">
        <h2>机构列表</h2>
        <div dx-tree-view="treeViewConfig"></div>
    </div>
    <div class="view">
        <h2 ng-hide="managerInfo.status">管理员列表<span class="record-count">(共<span ng-bind="managerGridConfig.dataSource.length"></span>个管理员)</span></h2>
        <a  class="btn btn-primary" ng-click="createManager()" ng-if="userInfo.role == 2" ng-hide="managerInfo.status">新建</a>
        <div dx-data-grid="managerGridConfig" ng-hide="managerInfo.status">
            <div data-options="dxTemplate: { name: 'orgIdCellTemplate' }">
                {{$parent.$parent.orgList[data.orgId].orgName}}
            </div>
            <div data-options="dxTemplate: { name: 'certificateTypeCellTemplate' }">
                {{data.certificateType == 1 ? '身份证':'驾驶证'}}
            </div>
            <div data-options="dxTemplate: { name: 'statusCellTemplate' }">
                <span  ng-class="{true: 'green', false: 'red'}[data.status == 10]">{{data.status == 10 ? '正常':'冻结'}}</span>
            </div>
            <div data-options="dxTemplate: { name: 'operationCellTemplate' }">
                <div class="operation">
                    <a ng-click="$parent.showManagerInfo(data)"><i></i>查看</a>
                    <a ng-if="$parent.userInfo.role == 2" ng-click="$parent.$parent.editManagerInfo(data)"><i></i>编辑</a>
                    <a ng-if="$parent.userInfo.role == 2" ng-click="$parent.$parent.updateStatus(data)"><i></i>{{data.status != 10 ? '解冻':'冻结'}}</a>
                </div>
            </div>
        </div>
        <h2 ng-show="managerInfo.status">管理员详情</h2>
        <form class="form-horizontal" ng-show="managerInfo.status" ng-submit="saveManager()">
            <div class="form-inline col-sm-12">
                <div class="col-xs-6 form-group">
                    <label for="userName" class="text-right">
                    <span class="required-color">
                        *
                    </span>
                        用户姓名
                    </label>
                    <input type="text" ng-model="managerInfo.userName" ng-disabled="type == 'view'" class="form-control" id="userName" required autofocus tabindex="1"/>
                </div>
            </div>
            <div class="form-inline col-sm-12">
                <div class="col-xs-6 form-group">
                    <label for="phone" class="text-right">
                    <span class="required-color">
                        *
                    </span>
                        手机号码
                    </label>
                    <input type="text" pattern="1[\d]{10}" title="请输入正确的手机号" ng-model="managerInfo.phone" ng-disabled="type == 'view'" class="form-control" id="phone" required tabindex="2"/>
                </div>
            </div>
            <div class="form-inline col-sm-12">
                <div class="col-xs-6 form-group">
                    <label for="password" class="text-right">
                    <span class="required-color">
                        *
                    </span>
                        密码
                    </label>
                    <input type="password" ng-model="managerInfo.password" ng-disabled="type == 'view'" class="form-control" id="password" required tabindex="3"/>
                </div>
            </div>
            <div class="form-inline col-sm-12">
                <div class="col-xs-6 form-group">
                    <label for="role" class="text-right">
                    <span class="required-color">
                        *
                    </span>
                        用户权限
                    </label>
                    <select ng-model="managerInfo.role" ng-disabled="type == 'view'" class="form-control" id="role" required tabindex="4">
                        <option value="1">浏览</option>
                        <option value="2">管理</option>
                    </select>
                </div>
            </div>
            <div class="form-inline col-sm-12">
                <div class="col-xs-6 form-group">
                    <label for="certificateType" class="text-right">
                    <span class="required-color">
                        *
                    </span>
                        证件类型
                    </label>
                    <select ng-model="managerInfo.certificateType" ng-disabled="type == 'view'" class="form-control" id="certificateType" required tabindex="5">
                        <option value="1">身份证</option>
                        <option value="2">护照</option>
                    </select>
                </div>
            </div>
            <div class="form-inline col-sm-12">
                <div class="col-xs-6 form-group">
                    <label for="certificateCode" class="text-right">
                    <span class="required-color">
                        *
                    </span>
                        证件号码
                    </label>
                    <input type="text" ng-model="managerInfo.certificateCode" ng-disabled="type == 'view'" class="form-control" id="certificateCode" required tabindex="6"/>
                </div>
            </div>
            <div class="form-inline col-xs-12 form-footer">
                <div class="col-sm-12">
                    <a class="col-sm-offset-3 col-sm-2 btn btn-primary" ng-click="managerInfo = {}">返回</a>
                    <input type="submit" value="提交" class="col-sm-offset-1 col-sm-2 btn btn-primary" ng-if="type != 'view'"/>
                </div>
            </div>
        </form>
    </div>
</div>
